//package com.plian.system.service.yth.impl;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.dj.DjPartyOrganizationMap;
//import com.plian.system.entity.yth.dj.PartyOrgMap;
//import com.plian.system.mapper.yth.dj.PartyOrgMapMapper;
//import com.plian.system.service.yth.IPartyOrgMapService;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.*;
//
///**
// * @Description:
// * @Author: jatpen
// * @Date: 2023/4/20 9:15 AM
// */
//@Slf4j
//@Service
//@DS("slave_1")
//public class PartyOrgMapServiceImpl extends ServiceImpl<PartyOrgMapMapper, PartyOrgMap> implements IPartyOrgMapService {
//
//    private final String YTH_DATASOURCE_TYPE = "3";
//
//    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
//    @Override
//    public List<DjPartyOrganizationMap> getSyncData(Date startTime, Date endTime) {
//        List<DjPartyOrganizationMap> djPartyOrganizationMaps = new ArrayList<>();
//        List<PartyOrgMap> partyOrgMaps = list(new LambdaQueryWrapper<PartyOrgMap>()
//                .gt(Optional.ofNullable(startTime).isPresent(), PartyOrgMap::getCreateTime, startTime)
//                .le(Optional.ofNullable(endTime).isPresent(), PartyOrgMap::getCreateTime, endTime)
//        );
//        if (CollectionUtil.isNotEmpty(partyOrgMaps)) {
//            djPartyOrganizationMaps = conversion(partyOrgMaps);
//        }
//        return djPartyOrganizationMaps;
//    }
//
//    /**
//     * 转换对象
//     *
//     * @param partyOrgMaps
//     * @return
//     */
//    private List<DjPartyOrganizationMap> conversion(List<PartyOrgMap> partyOrgMaps) {
//
//        List<DjPartyOrganizationMap> djPartyOrganizationMaps = new ArrayList<>();
//        for (PartyOrgMap partyOrgMap : partyOrgMaps) {
//            DjPartyOrganizationMap organizationMap = new DjPartyOrganizationMap();
//            organizationMap.setPartyOrganizationName(partyOrgMap.getOrgName());
//            organizationMap.setPartyOrganizationCode(Objects.toString(partyOrgMap.getOrgNameId()));
//            organizationMap.setPartyOrganizationAddr(partyOrgMap.getOrgAddress());
//            organizationMap.setPartyOrganizationDesp(partyOrgMap.getOrgIntroduction());
//            organizationMap.setDataSource(YTH_DATASOURCE_TYPE);
//            organizationMap.setDataSourceId(partyOrgMap.getId().toString());
//            djPartyOrganizationMaps.add(organizationMap);
//        }
//        return djPartyOrganizationMaps;
//    }
//}
